package com.qf.fcy.youshare.task;

import android.os.AsyncTask;
import com.qf.fcy.youshare.utils.HttpClientHelper;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: Alex[FR]
 * Date: 2015/2/5
 * Email: alex_fcy@163.com
 */
public class LoginTask extends AsyncTask<String, Integer, String> {
    @Override
    protected String doInBackground(String... params) {
        String ret = null;
        if (params != null && params.length >= 2) {

            HashMap<String, String> data = new HashMap<String, String>();
            data.put("name", params[0]);
            data.put("pwd", params[1]);

            String url = "http://open.doushangshang.com/user/login.php";
            byte[] bytes = HttpClientHelper.post(url, data);

            try {
                ret = new String(bytes, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        return ret;
    }
}
